*** set working directory
cd "/Users/Jeff/Dropbox/Research/Ongoing Research/ICM/JumpStart/Jeff/Replication Files"


use "jumpstart_final.dta", clear

*******************************************
********* Regression analysis *************
*******************************************
set matsize 5000

forvalues k = 1(1) 9 {
	rename L0`k'_ L`k'_
}
forvalues i = 1(1) 38 {
	replace L`i'_ = L`i'_ - 1
}
* Academic outcomes
rename L1_ likely_finish_hs
rename L2_ likely_grad_university
rename L3_ likely_good_job
rename L4_ likely_successful
egen std_likely_finish_hs = std(likely_finish_hs)
egen std_likely_grad_university = std(likely_grad_university)
egen std_likely_good_job = std(likely_good_job)
egen std_likely_successful = std(likely_successful)

* Scholastic outcomes
rename L5_ reads_alot
rename L6_ practice_math
rename L7_ succeed_highschl
rename L8_ learning_languages
rename L9_ quite_smart
egen std_reads_alot = std(reads_alot)
egen std_practice_math = std(practice_math)
egen std_succeed_highschl = std(succeed_highschl)
egen std_learning_languages = std(learning_languages)
egen std_quite_smart = std(quite_smart)

* Grit
rename L10_ easily_discouraged
gen neg_easily_discouraged = 4 - easily_discouraged
rename L11_ hard_worker
rename L12_ changes_mind
gen neg_changes_mind = 4 - changes_mind
rename L13_ difficulty_focusing
gen neg_difficulty_focusing = 4 - difficulty_focusing
rename L14_ finish_started
rename L15_ easily_distracted
gen neg_easily_distracted = 4 - easily_distracted
rename L16_ patient
egen std_easily_discouraged = std(easily_discouraged)
egen std_neg_easily_discouraged = std(neg_easily_discouraged)
egen std_hard_worker = std(hard_worker)
egen std_changes_mind = std(changes_mind)
egen std_neg_changes_mind = std(neg_changes_mind)
egen std_difficulty_focusing = std(difficulty_focusing)
egen std_neg_difficulty_focusing = std(neg_difficulty_focusing)
egen std_finish_started = std(finish_started)
egen std_easily_distracted = std(easily_distracted)
egen std_neg_easily_distracted = std(neg_easily_distracted)
egen std_patient = std(patient)

* Peer affiliation
rename L17_ easily_make_friend
rename L18_ avoid_social
gen neg_avoid_social = 4 - avoid_social
rename L19_ frequently_fights
gen neg_frequently_fights = 4 - frequently_fights
rename L20_ comforts_others
rename L21_ often_bullied
gen neg_often_bullied = 4 - often_bullied
egen std_easily_make_friend = std(easily_make_friend)
egen std_avoid_social = std(avoid_social)
egen std_neg_avoid_social = std(neg_avoid_social)
egen std_frequently_fights = std(frequently_fights)
egen std_neg_frequently_fights = std(neg_frequently_fights)
egen std_comforts_others = std(comforts_others)
egen std_often_bullied = std(often_bullied)
egen std_neg_often_bullied = std(neg_often_bullied)

* Behavioral outcomes
rename L22_ often_disobedient
gen neg_often_disobedient = 4 - often_disobedient
rename L23_ acts_younger
gen neg_acts_younger = 4 - acts_younger
rename L24_ kind_to_others
rename L25_ often_breaks_rules
gen neg_often_breaks_rules = 4 - often_breaks_rules
egen std_often_disobedient = std(often_disobedient)
egen std_neg_often_disobedient = std(neg_often_disobedient)
egen std_acts_younger = std(acts_younger)
egen std_neg_acts_younger = std(neg_acts_younger)
egen std_kind_to_others = std(kind_to_others)
egen std_often_breaks_rules = std(often_breaks_rules)
egen std_neg_often_breaks_rules = std(neg_often_breaks_rules)

* Spirituality
rename L26_ participates_youthgroup
rename L27_ asks_qs_god
rename L28_ enjoys_church
rename L29_ give_offering
egen std_participates_youthgroup = std(participates_youthgroup)
egen std_asks_qs_god = std(asks_qs_god)
egen std_enjoys_church = std(enjoys_church)
egen std_give_offering = std(give_offering)

* Self-control
rename L30_ easily_mad
gen neg_easily_mad = 4 - easily_mad
rename L31_ waits_to_speak
rename L32_ yells_when_mad
gen neg_yells_when_mad = 4 - yells_when_mad
rename L33_ easily_sit_still
rename L34_ makes_decisions_quickly
egen std_easily_mad = std(easily_mad)
egen std_neg_easily_mad = std(neg_easily_mad)
egen std_waits_to_speak = std(waits_to_speak)
egen std_yells_when_mad = std(yells_when_mad)
egen std_neg_yells_when_mad = std(neg_yells_when_mad)
egen std_easily_sit_still = std(easily_sit_still)
egen std_makes_decisions_quickly = std(makes_decisions_quickly)

* Positive identity
rename L35_ easily_upset
gen neg_easily_upset = 4 - easily_upset
rename L36_ less_value
gen neg_less_value = 4 - less_value
rename L37_ talks_about_future
rename L38_ positive_talk
egen std_easily_upset = std(easily_upset)
egen std_neg_easily_upset = std(neg_easily_upset)
egen std_less_value = std(less_value)
egen std_neg_less_value = std(neg_less_value)
egen std_talks_about_future = std(talks_about_future)
egen std_positive_talk = std(positive_talk)

** Potential mediators indices (directly from survey)
gen academic_index = (std_likely_finish_hs + std_likely_grad_university + ///
std_likely_good_job + std_likely_successful)/4
egen std_academic_index = std(academic_index)

gen scholastic_index = (std_reads_alot + std_practice_math + std_succeed_highschl + ///
std_learning_languages + std_quite_smart)/5
egen std_scholastic_index = std(scholastic_index)

gen grit_index = (std_neg_easily_discouraged + std_hard_worker + std_neg_changes_mind + ///
std_neg_difficulty_focusing + std_finish_started + std_neg_easily_distracted + std_patient)/7
egen std_grit_index = std(grit_index)

gen affiliation_index = (std_easily_make_friend + std_neg_avoid_social + std_neg_frequently_fights + ///
std_comforts_others + std_neg_often_bullied)/5
egen std_affiliation_index = std(affiliation_index)

gen behavioral_index = (std_neg_often_disobedient + std_neg_acts_younger + std_kind_to_others + ///
std_neg_often_breaks_rules)/4
egen std_behavioral_index = std(behavioral_index)

gen spiritual_index = (std_participates_youthgroup + std_asks_qs_god + std_enjoys_church + ///
std_give_offering)/4
egen std_spiritual_index = std(spiritual_index)

gen selfcontrol_index = (std_neg_easily_mad + std_waits_to_speak + std_neg_yells_when_mad + ///
std_easily_sit_still + std_makes_decisions_quickly)/5
egen std_selfcontrol_index = std(selfcontrol_index)

gen identity_index = (std_neg_easily_upset + std_neg_less_value + talks_about_future + ///
positive_talk)/4
egen std_identity_index = std(identity_index)

*** validity check ****

* grit 
corr std_neg_easily_discouraged std_hard_worker std_neg_changes_mind ///
std_neg_difficulty_focusing std_finish_started std_neg_easily_distracted std_patient
* Peer affiliation
corr std_easily_make_friend std_neg_avoid_social std_neg_frequently_fights ///
std_comforts_others std_neg_often_bullied
* Behavior
corr std_neg_often_disobedient std_neg_acts_younger std_kind_to_others ///
std_neg_often_breaks_rules
* Spiritual
corr std_participates_youthgroup std_asks_qs_god std_enjoys_church ///
std_give_offering
* Self-control
corr std_neg_easily_mad std_waits_to_speak std_neg_yells_when_mad ///
std_easily_sit_still std_makes_decisions_quickly
* Self-identity
corr std_neg_easily_upset std_neg_less_value talks_about_future ///
positive_talk
* all
corr std_neg_easily_discouraged std_hard_worker std_neg_changes_mind ///
std_neg_difficulty_focusing std_finish_started std_neg_easily_distracted ///
std_patient std_easily_make_friend std_neg_avoid_social std_neg_frequently_fights ///
std_comforts_others std_neg_often_bullied std_neg_often_disobedient ///
std_neg_acts_younger std_kind_to_others std_neg_often_breaks_rules ///
std_participates_youthgroup std_asks_qs_god std_enjoys_church ///
std_give_offering std_neg_easily_mad std_waits_to_speak std_neg_yells_when_mad ///
std_easily_sit_still std_makes_decisions_quickly std_neg_easily_upset ///
std_neg_less_value talks_about_future positive_talk


********************** Regression analysis ************************************


** regression grit index
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A5
reg std_grit_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA3.tex, keep(jumpstart gov_kinder) replace
test jumpstart = gov_kinder

* Appendix Table A5
reg std_grit_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA3.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Table 3
reg std_grit_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table3.tex, keep(jumpstart gov_kinder) replace
test jumpstart = gov_kinder

* Table 3
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
ivreghdfe std_grit_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table3.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

** regression peer affiliation index
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A5
reg std_affiliation_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA3.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Appendix Table A5
reg std_affiliation_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA3.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Table 3
reg std_affiliation_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table3.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Table 3
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
ivreghdfe std_affiliation_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table3.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

** regression self control index
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A5
reg std_selfcontrol_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA3.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Appendix Table A5
reg std_selfcontrol_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA3.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Table 3
reg std_selfcontrol_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table3.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Table 3
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
ivreghdfe std_selfcontrol_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table3.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

** regression self identity index
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A5
reg std_identity_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA3.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Appendix Table A5
reg std_identity_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA3.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Table 3
reg std_identity_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table3.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Table 3
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
ivreghdfe std_identity_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table3.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

** regression behavioral index
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A6
reg std_behavioral_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA4.tex, keep(jumpstart gov_kinder) replace
test jumpstart = gov_kinder

* Appendix Table A6
reg std_behavioral_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA4.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Table 4
reg std_behavioral_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table4.tex, keep(jumpstart gov_kinder) replace
test jumpstart = gov_kinder

* Table 4
reghdfe std_behavioral_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table4.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

** regression spiritual index
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A6
reg std_spiritual_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA4.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Appendix Table A6
reg std_spiritual_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA4.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Table 4
reg std_spiritual_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table4.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Table 4
reghdfe std_spiritual_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table4.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

** regression academic index
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A6
reg std_academic_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA4.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Appendix Table A6
reg std_academic_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA4.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Table 4
reg std_academic_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table4.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Table 4
reghdfe std_academic_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table4.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

** regression scholastic index
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A6
reg std_scholastic_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA4.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Appendix Table A6
reg std_scholastic_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA4.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Table 4
reg std_scholastic_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table4.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Table 4
reghdfe std_scholastic_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table4.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

***** Second stage mediation 

* Performed best in third grade
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"

reg best_in_third std_grit_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA8.tex, keep(std_grit_index jumpstart gov_kinder) replace

reg best_in_third std_affiliation_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA8.tex, keep(std_affiliation_index jumpstart gov_kinder)

reg best_in_third std_selfcontrol_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA8.tex, keep(std_selfcontrol_index jumpstart gov_kinder)

reg best_in_third std_behavioral_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA8.tex, keep(std_behavioral_index jumpstart gov_kinder)

reg best_in_third std_spiritual_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA8.tex, keep(std_spiritual_index jumpstart gov_kinder)

reg best_in_third std_identity_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA8.tex, keep(std_identity_index jumpstart gov_kinder)

reg best_in_third std_academic_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA8.tex, keep(std_academic_index jumpstart gov_kinder)

reg best_in_third std_scholastic_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA8.tex, keep(std_scholastic_index jumpstart gov_kinder)

reg best_in_third std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA8.tex, keep(std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index std_scholastic jumpstart gov_kinder)

reghdfe best_in_third too_young_third std_grit_index std_affiliation_index ///
std_selfcontrol_index std_behavioral_index std_spiritual_index std_identity_index ///
std_academic_index std_scholastic_index `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst 
outreg2 using TableA8.tex, keep (std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index std_scholastic_index jumpstart gov_kinder)

coefplot, keep(std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder) xline(0) msymbol(d) mfcolor(white) ///
levels(95) scheme(538bw) xtitle(Effect Size) rename (std_grit_index = "Grit index" ///
std_affiliation_index = "Peer affiliation index" std_selfcontrol_index = "Self-control index" ///
std_behavioral_index = "Behavioral index" std_spiritual_index = "Spiritual index" ///
std_identity_index = "Self-identity index" std_academic_index = "Academic expectations index" ///
std_scholastic_index = "Academic skills index" jumpstart = "Jumpstart" ///
gov_kinder = "Gov't kindergarten") title("A: Performed Best in Third Grade")
graph save "mediation_third_core.gph", replace

* Performed best in elementary
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"

reg best_in_elem std_grit_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA9.tex, keep(std_grit_index jumpstart gov_kinder) replace

reg best_in_elem std_affiliation_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA9.tex, keep(std_affiliation_index jumpstart gov_kinder)

reg best_in_elem std_selfcontrol_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA9.tex, keep(std_selfcontrol_index jumpstart gov_kinder)

reg best_in_elem std_behavioral_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA9.tex, keep(std_behavioral_index jumpstart gov_kinder)

reg best_in_elem std_spiritual_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA9.tex, keep(std_spiritual_index jumpstart gov_kinder)

reg best_in_elem std_identity_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA9.tex, keep(std_identity_index jumpstart gov_kinder)

reg best_in_elem std_academic_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA9.tex, keep(std_academic_index jumpstart gov_kinder)

reg best_in_elem std_scholastic_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA9.tex, keep(std_scholastic_index jumpstart gov_kinder)

reg best_in_elem std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA9.tex, keep(std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index std_scholastic jumpstart gov_kinder)

local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
ivreghdfe best_in_elem too_young_third std_grit_index std_affiliation_index ///
std_selfcontrol_index std_behavioral_index std_spiritual_index std_identity_index ///
std_academic_index std_scholastic_index `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst 
outreg2 using TableA9.tex, keep (std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index std_scholastic_index jumpstart gov_kinder)

coefplot, keep(std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder) xline(0) msymbol(d) mfcolor(white) ///
levels(95) scheme(538bw) xtitle(Effect Size) rename (std_grit_index = "Grit index" ///
std_affiliation_index = "Peer affiliation index" std_selfcontrol_index = "Self-control index" ///
std_behavioral_index = "Behavioral index" std_spiritual_index = "Spiritual index" ///
std_identity_index = "Self-identity index" std_academic_index = "Academic expectations index" ///
std_scholastic_index = "Academic skills index" jumpstart = "Jumpstart" ///
gov_kinder = "Gov't kindergarten") title("B: Performed Best in Elementary")
graph save "mediation_elem_core.gph", replace

* Placed in top section
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"

reg Section1_full std_grit_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA10.tex, keep(std_grit_index jumpstart gov_kinder) replace

reg Section1_full std_affiliation_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA10.tex, keep(std_affiliation_index jumpstart gov_kinder)

reg Section1_full std_selfcontrol_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA10.tex, keep(std_selfcontrol_index jumpstart gov_kinder)

reg Section1_full std_behavioral_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA10.tex, keep(std_behavioral_index jumpstart gov_kinder)

reg Section1_full std_spiritual_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA10.tex, keep(std_spiritual_index jumpstart gov_kinder)

reg Section1_full std_identity_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA10.tex, keep(std_identity_index jumpstart gov_kinder)

reg Section1_full std_academic_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA10.tex, keep(std_academic_index jumpstart gov_kinder)

reg Section1_full std_scholastic_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA10.tex, keep(std_scholastic_index jumpstart gov_kinder)

reg Section1_full std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA10.tex, keep(std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index std_scholastic jumpstart gov_kinder)

local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
ivreghdfe Section1_full too_young_third std_grit_index std_affiliation_index ///
std_selfcontrol_index std_behavioral_index std_spiritual_index std_identity_index ///
std_academic_index std_scholastic_index `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst 
outreg2 using TableA10.tex, keep (std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index std_scholastic_index jumpstart gov_kinder)

coefplot, keep(std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder) xline(0) msymbol(d) mfcolor(white) ///
levels(95) scheme(538bw) xtitle(Effect Size) rename (std_grit_index = "Grit index" ///
std_affiliation_index = "Peer affiliation index" std_selfcontrol_index = "Self-control index" ///
std_behavioral_index = "Behavioral index" std_spiritual_index = "Spiritual index" ///
std_identity_index = "Self-identity index" std_academic_index = "Academic expectations index" ///
std_scholastic_index = "Academic skills index" jumpstart = "Jumpstart" ///
gov_kinder = "Gov't kindergarten") title("C: Placed in Top Third Grade Section")
graph save "mediation_topsec_core.gph", replace

* Current enrollment
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"

reg child_enroll std_grit_index jumpstart gov_kinder too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA11.tex, keep(std_grit_index jumpstart gov_kinder) replace

reg child_enroll std_affiliation_index jumpstart gov_kinder too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA11.tex, keep(std_affiliation_index jumpstart gov_kinder)

reg child_enroll std_selfcontrol_index jumpstart gov_kinder too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA11.tex, keep(std_selfcontrol_index jumpstart gov_kinder)

reg child_enroll std_behavioral_index jumpstart gov_kinder too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA11.tex, keep(std_behavioral_index jumpstart gov_kinder)

reg child_enroll std_spiritual_index jumpstart gov_kinder too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA11.tex, keep(std_spiritual_index jumpstart gov_kinder)

reg child_enroll std_identity_index jumpstart gov_kinder too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA11.tex, keep(std_identity_index jumpstart gov_kinder)

reg child_enroll std_academic_index jumpstart gov_kinder too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA11.tex, keep(std_academic_index jumpstart gov_kinder)

reg child_enroll std_scholastic_index jumpstart gov_kinder too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA11.tex, keep(std_scholastic_index jumpstart gov_kinder)

reg child_enroll std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA11.tex, keep(std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index std_scholastic jumpstart gov_kinder)

reghdfe child_enroll too_young_enroll too_old_enroll std_grit_index std_affiliation_index ///
std_selfcontrol_index std_behavioral_index std_spiritual_index std_identity_index ///
std_academic_index std_scholastic_index `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst 
outreg2 using TableA11.tex, keep (std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index std_scholastic_index jumpstart gov_kinder)

coefplot, keep(std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder) xline(0) msymbol(d) mfcolor(white) ///
levels(95) scheme(538bw) xtitle(Effect Size) rename (std_grit_index = "Grit index" ///
std_affiliation_index = "Peer affiliation index" std_selfcontrol_index = "Self-control index" ///
std_behavioral_index = "Behavioral index" std_spiritual_index = "Spiritual index" ///
std_identity_index = "Self-identity index" std_academic_index = "Academic expectations index" ///
std_scholastic_index = "Academic skills index" jumpstart = "Jumpstart" ///
gov_kinder = "Gov't kindergarten") title("D: Currently Enrolled")
graph save "mediation_enrolled_core.gph", replace

gr combine mediation_third_core.gph mediation_elem_core.gph mediation_topsec_core.gph ///
mediation_enrolled_core.gph, scheme(538bw) xcommon 


*** Oster's coefficient stability tests

* Note: Set R_max equal to 1.3 times R in "long" regression


local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
reg best_in_elem std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, cluster(village_id)

psacalc delta std_selfcontrol_index, mcontrol(jumpstart gov_kinder) rmax(0.252)
psacalc beta std_selfcontrol_index, mcontrol(jumpstart gov_kinder) rmax(0.252) delta(1)

reg best_in_elem std_selfcontrol_index jumpstart gov_kinder too_young_third, cluster(village_id)

local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
reg child_enroll std_grit_index std_affiliation_index std_selfcontrol_index ///
std_behavioral_index std_spiritual_index std_identity_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, cluster(village_id)

psacalc delta std_scholastic_index, mcontrol(jumpstart gov_kinder too_young_enroll too_old_enroll) rmax(0.878)

reg child_enroll std_scholastic_index jumpstart gov_kinder too_young_enroll too_old_enroll, cluster(village_id)
